package com.dian.api.interceptor;

import com.dian.common.dto.UserDto;
import com.dian.common.local.UserLocal;
import com.gitee.easyopen.ApiContext;
import com.gitee.easyopen.interceptor.ApiInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class EntInterceptor extends ApiInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object serviceObj, Object argu)
            throws Exception {
        Long tenantId=ApiContext.getApiConfig().getAppSecretManager().getTenantId(ApiContext.getApiParam().fatchAppKey());
        UserDto userDto=new UserDto();
        userDto.setTenantId(tenantId);
        UserLocal.set(userDto);
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object serviceObj, Object argu,
                           Object result) throws Exception {
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object serviceObj,
                                Object argu, Object result, Exception e) throws Exception {

    }

}
